package com.study.dao;

import com.study.dao.impl.AwardInfoDAOImpl;
import com.study.dto.MedalDto;
import com.study.pojo.AwardInfo;
import org.junit.jupiter.api.Test;

import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;

/**
 * @PackgeName: com.study.dao
 * @ClassName: AwardInfoTest
 * @Author: 严志祥
 * Date: 2022-05-07 14:24
 * project name: web_project_medal
 * @Version:
 * @Description:
 */
public class AwardInfoTest {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    @Test
    public void test() throws ParseException, SQLException {
        AwardInfoDAO dao = new AwardInfoDAOImpl();
        dao.insert(new AwardInfo(1,1,2,"1分13秒",sdf.parse("2020-02-22")));
    }

    @Test
    public void test2() throws SQLException {
        AwardInfoDAO dao = new AwardInfoDAOImpl();
        List<MedalDto> medalDtos = dao.selectAward1("cn");
        medalDtos.forEach(item->{
            System.out.println(item.getSportingName());
            System.out.println(item.getAwardDate());
            System.out.println(item.getAthletesName());
        });
    }

    @Test
    public void test3(){
        AwardInfoDAO dao = new AwardInfoDAOImpl();
       try{
           List<MedalDto> list = dao.selectSporting("越野滑雪女子10公里");
           list.forEach(item->{
               System.out.println(item.getSportingBrief());
               System.out.println(item.getSportingName());
               System.out.println(item.getAwardDate());
               System.out.println(item.getAwardRanking());
               System.out.println(item.getAthletesName());
           });
       }catch (Exception e){
           e.printStackTrace();
       }
    }
}
